<?php
global $SESSION;

/**
 * Get loggedin user
 * @return bool|User
 */
function get_loggedin_user() {
    if (isset($_SESSION['user'])) {
        return $_SESSION['user'];
    }
    return false;
}

/**
 * @return bool|int
 */
function get_loggedin_userid() {
    if (isset($_SESSION['user'])) {
        return $_SESSION['user']->id;
    }
    return false;
}

/**
 * Check if user logged in
 * @return bool
 */
function isloggedin() {
    if (isset($_SESSION['user'])) {
        return true;
    }
    return false;
}